<?php
require 'kernel/common.php';
if(!$Session->check_admin()) redirect('index.php');

$template->set_filenames(array('utilisateur' => 'template/utilisateur.tpl'));

// Recuperation de la liste utilisateur
$Query = "SELECT * FROM immo_user WHERE id = '1'";
$Sql = $db->sql_query($Query);
$User = $db->sql_fetchobject($Sql);

$template->assign_block_vars('user', array(
'V_ID'	=>	$User->id,
'V_IDENTIFIANT'	=>	$User->identifiant,
'V_NOM'	=>	$User->nom,
'V_PRENOM'	=>	$User->prenom,
'V_EMAIL'	=>	'',
'V_ACTION'	=>	'',
));

$Query = "SELECT * FROM immo_user WHERE id > 1 ORDER BY nom, prenom";
$Sql = $db->sql_query($Query);

while($User = $db->sql_fetchobject($Sql))
{
	$EditUser = '<a href="./utilisateur_edition.php?id='. $User->id .'" title=""><img src="./images/edit.png" style="border:none; height:20px; width:20px" /></a>';
	$ChangePassword = '<a href="./utilisateur_password.php?id='. $User->id .'" title=""><img src="./images/key.png" style="border:none; height:20px; width:20px" /></a>';
	$DelUser = '<a href="./utilisateur_supprime.php?id='. $User->id .'" title=""><img src="./images/del.png" style="border:none; height:20px; width:20px" /></a>';
	$action = $EditUser .'&nbsp;&nbsp;'. $ChangePassword .'&nbsp;&nbsp;'.$DelUser;
	$template->assign_block_vars('user', array(
	'V_ID'	=>	$User->id,
	'V_IDENTIFIANT'	=>	$User->identifiant,
	'V_NOM'	=>	$User->nom,
	'V_PRENOM'	=>	$User->prenom,
	'V_EMAIL'	=>	$User->email,
	'V_ACTION'	=>	$action,
	));
}

$template->assign_vars(array(
'L_NOM'	=>	$lang['Nom'],
'L_PRENOM'	=>	$lang['Prenom'],
'L_GESTION_UTILISATEUR'	=>	$lang['Gestion_utilisateur'],
'L_IDENTIFIANT'	=>	$lang['Identifiant'],
'L_EMAIL'	=>	$lang['Email'],
'L_ACTION'	=>	$lang['Action'],
'L_RETOUR'	=>	$lang['Retour'],
));

$template->display('utilisateur');
require 'footer.php';
?>